home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 July
/
Macworld (1999-07).dmg
/
Serious Software
/
OpenWorld demo 2.0
/
Development
/
SingleTag
/
Modification Date
/
ModDate.c
next >
Wrap
Text File
|
1999-04-27
|
2KB
|
84 lines
/* File: ModDate.c
Copyright (c) 1999 Marco Bambini. All rights reserved.
Description: return the modification date of the file
*/
#include "OpenWorld_plugIn.h"
#include "OpenWorld_utils.h"
#include <CodeFragments.h>
#include <Files.h>
#include <Packages.h>
long GetFileModDate(FSSpec *spec,short fRef);
Boolean main (dataPtr param)
{
switch (param->message)
{
case init_message:
{
param->version=kVersion;
param->customData=kUnused;
}
break;
case run_message:
{
long date;
Str255 resultStr;
long dim;
// get the file modification date
date=GetFileModDate(&(param->myFile),param->fRef);
if (date==-1) return NULL;
if (up_strcmp(param->search,"SHORT")==NULL) IUDateString(date,shortDate,resultStr); // short date: 10/1/98
else
if (up_strcmp(param->search,"LONG")==NULL) IUDateString(date,longDate,resultStr); // long date: Monday, February 1, 1998
else
if (up_strcmp(param->search,"ABBR")==NULL) IUDateString(date,abbrevDate,resultStr); // abbrev. date: Mon, Feb 1, 1998
else
IUDateString(date,shortDate,resultStr); //default
// get the size of the string
dim=resultStr[0];
// convert the result into an HTML string
param->outputText=OW_TextToHTML(param,&resultStr[1],&dim);
if (param->outputText) param->dim=dim;
}
break;
case stop_message:
{
// dispose the buffer
OW_DisposePtr(param,param->outputText);
}
break;
case end_message:
{
// do nothing
}
break;
}
return kSingleTag;
}
long GetFileModDate(FSSpec *spec,short fRef)
{
CInfoPBRec pb;
OSErr err;
pb.hFileInfo.ioFDirIndex = 0;
pb.hFileInfo.ioNamePtr = spec->name;
pb.hFileInfo.ioVRefNum = spec->vRefNum;
pb.hFileInfo.ioFRefNum = fRef;
pb.hFileInfo.ioDirID = spec->parID;
err=PBGetCatInfoSync(&pb);
if (err==noErr) return (pb.hFileInfo.ioFlMdDat);
else return -1;
}